package com.jinxin.platform.cdzxkacs.controller;

import com.jinxin.platform.base.common.pojo.JsonResult;
import com.jinxin.platform.cdzxkacs.service.IAcsDeviceService;
import com.jinxin.platform.cdzxkacs.service.IAcsRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * All rights Reserved, Designed By www.beonelot.com
 *
 * @version: V1.0
 * @Copyright: www.beonelot.com Inc. All rights reserved.
 * @Description：
 * @Date: 2021-03-02
 * @Author: Lingnan
 **/
@RestController
@RequestMapping("/unAuth")
@Slf4j
public class UauthController {
    @Autowired
    private IAcsRecordService recordService;
    @Autowired
    private IAcsDeviceService deviceService;

    @RequestMapping("/zxkRecord/top10")
    public JsonResult getTop10OpenRecords(){
        HashMap param2 = new HashMap();
        param2.put("page", 1);
        param2.put("limit", 10);
        return JsonResult.ok(recordService.listPage(param2));
    }

    // 获取开门的统计信息，出入流量和访客数量统计
    @GetMapping("/openRecord/getOpenStatistics")
    public JsonResult getOpenStatistics(String companyId){
        Map<String,Object> resultMap = new HashMap<>();
        HashMap param = new HashMap();
        param.put("companyId",companyId);
        int openCount = recordService.listPageCount(param);
        resultMap.put("openCount", openCount);
        return JsonResult.ok(resultMap);
    }

    @GetMapping("/openRecord/countDeviceStatus")
    public JsonResult countDeviceStatus(String communityId){
        return deviceService.countDeviceStatus(communityId);
    }
}
